package array;

/**
 * @program: util
 * @description: 累加二维数组的第二纬度
 * @author: zhouliangliang
 * @create: 2019-05-08 10:55
 **/
public class AccArray {

    public  String add(String a, String b) {
        Integer av = Integer.valueOf(a);
        Integer bv = Integer.valueOf(b);
        Integer sum = av+bv;
        return sum.toString();
    }

    public void tt(String array[][]) {
        String array1[][] = new String[array.length][];

        //把数组的第二纬数字加起来
        for(int i=0; i<array.length; i++) {
            array1[i] = array[i];
            if(i == 0) {
                continue;
            }
            for(int j=0; j<array[i].length; j=j+2) {
                array1[i][j+1] = add(array[i-1][j+1], array[i][j+1]);
            }
        }

        //输出结果
        for(int i=0; i<array1.length; i++) {
            for(int j=0; j<array1[i].length; j++) {
                System.out.println(array[i][j]);
            }
        }
    }



    public static void main(String[] args) {
        String array[][] = new String[][] {
                {"2018-10","211"},
                {"2018-11","24"},
                {"2018-12","25"},
                {"2019-01","25"},
                {"2019-02","9"},
                {"2019-03","17"},
                {"2019-04","23"}};
        new AccArray().tt(array);

    }
}
